package cc.mcyx.ychat.config

import com.corundumstudio.socketio.SocketIOServer
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
open class WebSocketConfig(
    @Value("\${ychat.ws.port}")
    var port: Int
) {
    @Bean
    open fun socketIO(): SocketIOServer {
        return SocketIOServer(
            com.corundumstudio.socketio.Configuration().also { it.port = this.port }).also { it.start() }
    }
}